package com.liyuxiang.controller;

import com.liyuxiang.domain.ResponseResult;
import com.liyuxiang.pojo.entity.User;
import com.liyuxiang.pojo.vo.UserVo;
import com.liyuxiang.service.LoginService;
import com.liyuxiang.service.impl.UserDetailsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Objects;

/**
 * 登录接口
 */
@RestController
public class LoginController {

    @Autowired
    LoginService loginService;

    @PostMapping("/user/login")
    public ResponseResult login(@RequestBody User user, HttpServletResponse response){
        return loginService.login(user,response);

    }

    @RequestMapping("/user/logout")
    public ResponseResult logout(){
        return loginService.logout();
    }
}
